#include "simplestate.h"

//struct EvStartStop : sc::event< EvStartStop > {};
//struct EvReset : sc::event< EvReset > {};

struct Active;
struct StopWatch : StateMachine< StopWatch, Active > 
{
	StopWatch()
	{
		std::cout << "StopWatch" << std::endl;
	}

	~StopWatch()
	{
		std::cout << "~StopWatch" << std::endl;
	}
};

struct Stopped;

// The simple_state class template accepts up to four parameters:
// - The third parameter specifies the inner initial state, if
//   there is one. Here, only Active has inner states, which is
//   why it needs to pass its inner initial state Stopped to its
//   base
// - The fourth parameter specifies whether and what kind of
//   history is kept

// Active is the outermost state and therefore needs to pass the
// state machine class it belongs to
struct Active : SimpleState<Active, StopWatch, Stopped > {
	Active()
	{
		std::cout << "Active" << std::endl;
	}

	~Active()
	{
		std::cout << "~Active" << std::endl;
	}
};

// Stopped and Running both specify Active as their Context,
// which makes them nested inside Active
struct Running : SimpleState< Running, Active > 
{
	Running()
	{
		std::cout << "Running" << std::endl;
	}

	~Running()
	{
		std::cout << "~Running" << std::endl;
	}
};
struct Stopped : SimpleState< Stopped, Active > 
{
	Stopped()
	{
		std::cout << "Stopped" << std::endl;
	}

	~Stopped()
	{
		std::cout << "~Stopped" << std::endl;
	}
};

// Because the context of a state must be a complete type (i.e.
// not forward declared), a machine must be defined from
// "outside to inside". That is, we always start with the state
// machine, followed by outermost states, followed by the direct
// inner states of outermost states and so on. We can do so in a
// breadth-first or depth-first way or employ a mixture of the
// two.

int main()
{
	StopWatch myWatch;
	myWatch.initiate();
	return 0;
}

//struct Greeting;
//struct Machine : StateMachine<Machine, Greeting>
//{
//
//};
//
//struct Stopped;
//struct Greeting : SimpleState<Greeting, Machine, Stopped>
//{
//	Greeting()
//	{
//		std::cout << "hello Greeting" << std::endl;
//	}
//
//	~Greeting()
//	{
//		std::cout << "hello ~Greeting" << std::endl;
//	}
//};
//
//struct Stopped : SimpleState<Stopped, Greeting>
//{
//	Stopped()
//	{
//		std::cout << "hello Stopped" << std::endl;
//	}
//
//	~Stopped()
//	{
//		std::cout << "hello ~Stopped" << std::endl;
//	}
//};
//
//int main()
//{
//	Machine m;
//	m.initiate();
//
//	return 0;
//}